﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_LayoutForm.cshtml";
}
<script>
    $(function () {
        initSearchControl({
            id: 'areaSearch',
            name: 'AreaName',
            value :'@Model.AreaName',
            displayText : '@this.ViewBag.AreaText',
            height:280,
            dataSource: @Html.Raw(this.ViewBag.areaList),
            colModel: [{
                        label: 'ID',
                        name: 'ID',
                        width: 30,
                        key: true
                    }, {
                        label: '区域名称',
                        width: 60,
                        name: 'areaName'
                    }]
        });
    });
    function submitForm(callback) {
          $.submitForm({
            url: "SubmitForm",
            data: $('form').serializeForm(),
            callback: callback,
            success: function (data) {
                if(data.indexOf("成功")<0)
                {
                    alert(data);
                    this.close = false;
                }
            }
        });
    }
</script>
<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <form class="form-horizontal" style="margin-top: 30px">
            <input  type="hidden" name= "ID" value="@Model.ID" />
            <input  type="hidden" name= "AreaNo" value="@Model.AreaNo" />
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    ID
                </label>
                <div class="col-sm-9 col-xs-9">
                    <input id="txtId" readonly type="text" class="col-xs-10 col-sm-10" />
                    <script>
                        var id = $("form input[name='ID']").val();
                        if (id == -1)
                            $("#txtId").val("新增");
                        else
                            $("#txtId").val(id);
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    窗口名称
                </label>
                <div class="col-sm-9 col-xs-9">
                    <input type="text" name="Name" value="@Model.Name"  autocomplete="off" class="col-xs-10 col-sm-10" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    窗口号
                </label>
                <div class="col-sm-9 col-xs-9">
                    <input type="text" name="Number" value="@Model.Number" autocomplete="off" class="col-xs-10 col-sm-10"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    窗口状态
                </label>
                <div class="col-sm-9 col-xs-9">
                    <select name="State" class="col-xs-10 col-sm-10">
                        @foreach (var item in this.ViewBag.State)
                        { 
                            <option value="@item.Value">@item.Name</option>
                        }
                    </select>
                    <script>
                        $("form select[name='State']").val("@(string.IsNullOrEmpty(Model.State) ? "1" : Model.State)"); 
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    呼叫器编号
                </label>
                <div class="col-sm-9 col-xs-9">
                    <input type="text" name="CallNumber" value="@Model.CallNumber"  autocomplete="off" class="col-xs-10 col-sm-10" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 col-xs-3">
                    区域名称
                </label>
                <div class="col-sm-9 col-xs-9">
                    <input id="areaSearch" displaymember='areaName' valuemember='ID' type="text" autocomplete="off"
                        class="col-xs-10 col-sm-10" />
                </div>
            </div>
            </form>
        </div>
    </div>
</div>
